/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Administrator
 */
@Entity
@Table(name = "CV")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Cv.findAll", query = "SELECT c FROM Cv c"),
    @NamedQuery(name = "Cv.findByCvid", query = "SELECT c FROM Cv c WHERE c.cvid = :cvid")})
public class Cv implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "CVID", nullable = false, length = 50)
    private String cvid;
    @JoinColumn(name = "VacancyID", referencedColumnName = "VacancyID")
    @ManyToOne
    private Vacancy vacancyID;
    @JoinColumn(name = "ApplicantID", referencedColumnName = "ApplicantID")
    @ManyToOne
    private Applicant applicantID;
    @OneToMany(mappedBy = "cvid")
    private List<Interview> interviewList;

    public Cv() {
    }

    public Cv(String cvid) {
        this.cvid = cvid;
    }

    public String getCvid() {
        return cvid;
    }

    public void setCvid(String cvid) {
        this.cvid = cvid;
    }

    public Vacancy getVacancyID() {
        return vacancyID;
    }

    public void setVacancyID(Vacancy vacancyID) {
        this.vacancyID = vacancyID;
    }

    public Applicant getApplicantID() {
        return applicantID;
    }

    public void setApplicantID(Applicant applicantID) {
        this.applicantID = applicantID;
    }

    @XmlTransient
    public List<Interview> getInterviewList() {
        return interviewList;
    }

    public void setInterviewList(List<Interview> interviewList) {
        this.interviewList = interviewList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cvid != null ? cvid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Cv)) {
            return false;
        }
        Cv other = (Cv) object;
        if ((this.cvid == null && other.cvid != null) || (this.cvid != null && !this.cvid.equals(other.cvid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.Cv[ cvid=" + cvid + " ]";
    }
    
}
